#!/usr/local/bin/php
<?php

if (!empty($_SERVER['argv']) && count($_SERVER['argv']) > 1) {
    $_SERVER['HTTP_HOST'] = 'novosti-futbola.my';
} else {
    $_SERVER['HTTP_HOST'] = 'novosti-futbola.ru';
}

require dirname(__FILE__) . '/../config.php';

$news_model = new NewsModel(DbConnection::COMMON_SPACE, true);
$list = $news_model->getList(0, 100, News::STATUS_ACTIVE);

$content = '<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

foreach ($list as $id => $news) {
    /* @var $news News */
    $content .= '
    <url>
        <loc>http://'.$_SERVER['HTTP_HOST'] . $news->getGeneratedUrl().'</loc>
        <lastmod>'.date("c").'</lastmod>
        <changefreq>always</changefreq>
        <priority>1.0</priority>
    </url>';
    
}

$content .= '</urlset>';

file_put_contents(dirname(__FILE__) . '/../sitemap.xml', $content);
?>